#!/bin/bash
#########################################################
#							#
# This are NScripts v3.6				#
#							#
# Licensed under the GNU GENERAL PUBLIC LICENSE 3	#
#							#
# Copyright 2007 - 2009 Christopher Bratusek		#
#							#
#########################################################

echo $NAUTILUS_SCRIPT_SELECTED_URIS > ~/.gnome2/temp_mkmd5_list

for file in $(cat ~/.gnome2/temp_mkmd5_list); do

	if [[ -d "$file" ]]; then
		exit
	fi

	filename=$(echo $file | sed -e 's/file:\/\///g' -e 's/\%20/\ /g')
	shortfile=$(echo $file | sed -e 's/.*\///g' -e 's/\%20/\ /g')
	md5sum "$filename" > "$shortfile.md5"

	if [[ -a $shortfile.md5 ]]; then
		echo -e "\n========================================================" >> ~/.gnome2/mkmd5_result
		echo "MD5-Sum for $shortfile successfully created" >> ~/.gnome2/mkmd5_result;
	else	echo -e "\n========================================================" >> ~/.gnome2/mkmd5_result
		echo "MD5-Sum for $shortfile not created" >> ~/.gnome2/mkmd5_result;
	fi

done

zenity --text-info --title "Result" --width=640 --height=480 --shortfile=$HOME/.gnome2/mkmd5_result

rm -f ~/.gnome2/temp_mkmd5_list ~/.gnome2/mkmd5_result
